﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using DevExpress.XtraEditors;

namespace PRE.Catalog
{

    public struct pic_Hinh
    {
        static pic_Hinh()
        {
            
        }
    }
    public partial class FrmCapnhatnhanvien : PRE.Catalog.FrmBase
    {
        #region Variable
        DAL.EntitiesDAL.NhanvienDAL _dal = new DAL.EntitiesDAL.NhanvienDAL();
        BLL.EntitiesBLL.NhanvienBLL _bll = new BLL.EntitiesBLL.NhanvienBLL();
        
        DataTable _dtb = new DataTable();
        DataTable _dtb1 = new DataTable();
        DataTable _dtb2 = new DataTable();
        DataTable _dtb3 = new DataTable();
        DataTable _dtb4 = new DataTable();
        DataTable _dtb5 = new DataTable();
        DataTable _dtb6 = new DataTable();
        #endregion

        #region Inits
        public FrmCapnhatnhanvien()
        {
            InitializeComponent();
        }
        #endregion

        #region Form Load
        private void FrmCapnhatnhanvien_Load(object sender, EventArgs e)
        {
            PerformRefresh();
        }
        #endregion

        #region override

        protected override void PerformAdd()
        {

            _dtb1 = _dal.Select_Phongban();
            _dtb2 = _dal.Select_Mucluong();
            _dtb3 = _dal.Select_Bachoc();
            _dtb4 = _dal.Select_Dantoc();
            _dtb5 = _dal.Select_Tongiao();
            _dtb6 = _dal.Select_Hocvan();

            cbo_Maphongban.Properties.DataSource = _dtb1;
            cbo_Mucluong.Properties.DataSource = _dtb2;
            cbo_Mabac.Properties.DataSource = _dtb3;
            cbo_Dantoc.Properties.DataSource = _dtb4;
            cbo_Tongiao.Properties.DataSource = _dtb5;
            cbo_Hocvan.Properties.DataSource = _dtb6;
            txt_Chuyenmon.ResetText();
    


            DataTable _ma = _dal.Select_Max();
            if (_ma != null)
                if (_ma.Rows.Count > 0)
                {
                    string ma = _bll.AddID(_ma.Rows[0]["Ma"] + "");
                    txt_Manhanvien.Text = ma;

                    ReadOnlyControl(false);
                    ClearDataBindings();
                    ChangeStatus(false);
                    ResetText();
                    dte_Ngaysinh.EditValue = DateTime.Now;
                    dte_Ngaythamgiacongtac.EditValue = DateTime.Now;
                    dte_Ngaynghicongtac.EditValue = DateTime.Now.AddYears(20);
                    txt_Manhanvien.Properties.ReadOnly = true;

                    layoutControlItemBrowse.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

                    layoutControlItemChucVu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem_Chuyenmon.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem_Ngoaingu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem_Chinhtri.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem_Supham.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem_Tinhoc.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;


                    txt_Tenbac.Properties.ReadOnly = true;
                    txt_Tenphongban.Properties.ReadOnly = true;
                    txt_Hoten.Focus();
                }
          
            base.PerformAdd();
        }

        protected override void PerformCancel()
        {
            ChangeStatus();
            PerformRefresh();
            base.PerformCancel();
        }

        protected override void PerformDelete()
        {
            var id1 = grvNhanvien.GetFocusedRowCellValue("MANHANVIEN") + "";
           
            DialogResult result;
            var ok = _dal.Delete(id1);
            result = XtraMessageBox.Show("Bạn có chắc xóa không ? ", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (result == DialogResult.OK)
            {
                if (ok)
                {
                    PerformRefresh();
                }
                else
                    XtraMessageBox.Show("Lỗi! Không xóa được", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            base.PerformDelete();
        }

        protected override void PerformEdit()
        {
            ReadOnlyControl(false);
            txt_Manhanvien.Properties.ReadOnly = true;
            layoutControlItemBrowse.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItemChucVu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layoutControlItem_Chuyenmon.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layoutControlItem_Ngoaingu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layoutControlItem_Chinhtri.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layoutControlItem_Supham.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layoutControlItem_Tinhoc.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            txt_Tenbac.Properties.ReadOnly = true;
            txt_Tenphongban.Properties.ReadOnly = true;
            base.PerformEdit();
        }

        protected override void PerformPrint()
        {
            base.PerformPrint();
        }

        protected override void PerformRefresh()
        {
            ReadOnlyControl();
            LoadData();
            ChangeStatus();
            ResetText();
            layoutControlItemChucVu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItem_Chuyenmon.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItem_Ngoaingu.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItem_Chinhtri.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItem_Supham.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            layoutControlItem_Tinhoc.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

            if (_dtb != null)
            {
                ClearDataBindings();
                if (_dtb.Rows.Count > 0) DataBindingControl();
            }
            base.PerformRefresh();
        }

        protected override void PerformSave()
        {
            #region IsAdd
            if (IsAdd)
            {
                try
                {
                    int i = 0;
                    if (txt_Hesoluong.Text == "")
                    {
                        txt_Hesoluong.Text = i.ToString();
                    }
                    int j = 0;
                    if (txt_Hesophucap.Text == "")
                    {
                        txt_Hesophucap.Text = j.ToString();
                    }

                    var name_Hoten = Proper(txt_Hoten.Text);
                    var name_Quequan = Proper(txt_Quequan.Text);
                    var name_Choohiennay = Proper(txt_Choohiennay.Text);
                    var o = new DAL.Entities.Nhanvien()
                    {
                        MANHANVIEN = txt_Manhanvien.Text,
                        HOTEN = name_Hoten,
                        GIOITINH = Convert.ToBoolean(radio_Gioitinh.EditValue),
                        NGAYSINH = Convert.ToDateTime(dte_Ngaysinh.EditValue),
                        CMND = Convert.ToString(txt_Cmnd.Text),
                        DANTOC = Convert.ToString(cbo_Dantoc.EditValue),
                        TONGIAO = Convert.ToString(cbo_Tongiao.EditValue),
                        QUEQUAN = name_Quequan,
                        CHOOHIENNAY = name_Choohiennay,
                        TRINHDOHOCVAN = Convert.ToString(cbo_Hocvan.EditValue),
                        DIENTHOAI=txt_Sodienthoai.Text,
                        EMAIL=txt_Email.Text,
                        NGAYTHAMGIACONGTAC = Convert.ToDateTime(dte_Ngaythamgiacongtac.EditValue),
                        NGAYNGHICONGTAC = Convert.ToDateTime(dte_Ngaynghicongtac.EditValue),
                        MUCLUONG = Convert.ToString(cbo_Mucluong.EditValue),
                        MABAC = Convert.ToString(cbo_Mabac.EditValue),
                        MAPHONGBAN = Convert.ToString(cbo_Maphongban.EditValue),
                        HESOLUONG = Convert.ToDouble(txt_Hesoluong.Text),  
                        HESOPHUCAP = Convert.ToDouble(txt_Hesophucap.Text),
                        IMAGES = txt_TenFile.Text
                    };

                    var oki = _dal.Insert(o);
                    if (oki)
                    {
                        XtraMessageBox.Show("Đã lưu thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        PerformRefresh();
                        ChangeStatus(false);
                        PerformAdd();
                    }
                    else
                    {
                        XtraMessageBox.Show("Lỗi! Lưu thất bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ChangeStatus(false);
                        ReadOnlyControl(false);
                    }
                }
                catch {}

            }
            #endregion

            #region IsEdit
            if (IsEdit)
            {
                try
                {
                    int i = 0;
                    if (txt_Hesoluong.Text == "")
                    {
                        txt_Hesoluong.Text = i.ToString();
                    }
                    int j = 0;
                    if (txt_Hesophucap.Text == "")
                    {
                        txt_Hesophucap.Text = j.ToString();
                    }
                    var id1 = grvNhanvien.GetFocusedRowCellValue("MANHANVIEN") + "";
                    var name_Hoten = Proper(txt_Hoten.Text);
                    var name_Quequan = Proper(txt_Quequan.Text);
                    var name_Choohiennay = Proper(txt_Choohiennay.Text);
                    var o = new DAL.Entities.Nhanvien()
                    {
                        //MANHANVIEN = txt_Manhanvien.Text,
                        //HOTEN = name_Hoten,
                        //GIOITINH = Convert.ToBoolean(radio_Gioitinh.EditValue),
                        //NGAYSINH = DateTime.ParseExact(dte_Ngaysinh.Text, "dd/MM/yyyy", null),
                        //CMND = Convert.ToString(txt_Cmnd.Text),
                        //DANTOC = Convert.ToString(cbo_Dantoc.EditValue),
                        //TONGIAO = Convert.ToString(cbo_Tongiao.EditValue),
                        //QUEQUAN = name_Quequan,
                        //CHOOHIENNAY = name_Choohiennay,
                        //TRINHDOHOCVAN = Convert.ToString(cbo_Hocvan.EditValue),
                        //DIENTHOAI = txt_Sodienthoai.Text,
                        //EMAIL = txt_Email.Text,
                        //NGAYTHAMGIACONGTAC = DateTime.ParseExact(dte_Ngaythamgiacongtac.Text, "dd/MM/yyyy", null),
                        //NGAYNGHICONGTAC = DateTime.ParseExact(dte_Ngaynghicongtac.Text, "dd/MM/yyyy", null),
                        //MUCLUONG = Convert.ToString(cbo_Mucluong.EditValue),
                        //MABAC = Convert.ToString(cbo_Mabac.EditValue),
                        //MAPHONGBAN = Convert.ToString(cbo_Maphongban.EditValue),
                        //HESOLUONG = Convert.ToDouble(txt_Hesoluong.Text),
                        //HESOPHUCAP = Convert.ToDouble(txt_Hesophucap.Text),
                        //IMAGES = txt_TenFile.Text
                        MANHANVIEN = txt_Manhanvien.Text,
                        HOTEN = name_Hoten,
                        GIOITINH = Convert.ToBoolean(radio_Gioitinh.EditValue),
                        NGAYSINH = Convert.ToDateTime(dte_Ngaysinh.EditValue),
                        CMND = Convert.ToString(txt_Cmnd.Text),
                        DANTOC = Convert.ToString(cbo_Dantoc.EditValue),
                        TONGIAO = Convert.ToString(cbo_Tongiao.EditValue),
                        QUEQUAN = name_Quequan,
                        CHOOHIENNAY = name_Choohiennay,
                        TRINHDOHOCVAN = Convert.ToString(cbo_Hocvan.EditValue),
                        DIENTHOAI = txt_Sodienthoai.Text,
                        EMAIL = txt_Email.Text,
                        NGAYTHAMGIACONGTAC = Convert.ToDateTime(dte_Ngaythamgiacongtac.EditValue),
                        NGAYNGHICONGTAC = Convert.ToDateTime(dte_Ngaynghicongtac.EditValue),
                        MUCLUONG = Convert.ToString(cbo_Mucluong.EditValue),
                        MABAC = Convert.ToString(cbo_Mabac.EditValue),
                        MAPHONGBAN = Convert.ToString(cbo_Maphongban.EditValue),
                        HESOLUONG = Convert.ToDouble(txt_Hesoluong.Text),
                        HESOPHUCAP = Convert.ToDouble(txt_Hesophucap.Text),
                        IMAGES = txt_TenFile.Text
                    };

                    var oki = _dal.Update(o);

                    if (oki)
                    {
                        XtraMessageBox.Show("Đã lưu thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadData();
                        ChangeStatus();
                    }
                    else
                    {
                        XtraMessageBox.Show("Lỗi! Lưu thất bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ChangeStatus(false);
                        ReadOnlyControl(false);
                    }
                }
                catch  {}
                    
             }
            #endregion

            base.PerformSave();
        }

        protected override void ResetText()
        {
            cbo_Maphongban.ResetText();
            cbo_Mabac.ResetText();
            cbo_Dantoc.ResetText();
            cbo_Tongiao.ResetText();
            cbo_Hocvan.ResetText();
            txt_Chuyenmon.ResetText();
            txt_Choohiennay.ResetText();
            txt_Chungchichinhtri.ResetText();
            txt_Chungchingoaingu.ResetText();
            txt_Chungchisupham.ResetText();
            txt_Chungchitinhoc.ResetText();
            txt_Cmnd.ResetText();
            txt_Email.ResetText();
            txt_Hesoluong.ResetText();
            txt_Hesophucap.ResetText();
            txt_Hoten.ResetText();
            txt_Quequan.ResetText();
            txt_Sodienthoai.ResetText();
            txt_Tenbac.ResetText();
            txt_Tenchucvu.ResetText();
            txt_TenFile.ResetText();
            txt_Tenphongban.ResetText();
            radio_Gioitinh.ResetText();

            base.ResetText();
        }

        protected override void ClearDataBindings()
        {
            txt_Manhanvien.DataBindings.Clear();
            txt_Hoten.DataBindings.Clear();
            txt_Choohiennay.DataBindings.Clear();
            txt_Chungchichinhtri.DataBindings.Clear();
            txt_Chungchingoaingu.DataBindings.Clear();
            txt_Chungchisupham.DataBindings.Clear();
            txt_Chungchitinhoc.DataBindings.Clear();
            txt_Chuyenmon.DataBindings.Clear();
            txt_Cmnd.DataBindings.Clear();
            txt_Email.DataBindings.Clear();
            txt_Hesoluong.DataBindings.Clear();
            txt_Hesophucap.DataBindings.Clear();
            txt_Quequan.DataBindings.Clear();
            txt_Sodienthoai.DataBindings.Clear();
            txt_Tenbac.DataBindings.Clear();
            txt_Tenchucvu.DataBindings.Clear();
            txt_TenFile.DataBindings.Clear();
            txt_Tenphongban.DataBindings.Clear();
            cbo_Hocvan.DataBindings.Clear();
            cbo_Mucluong.DataBindings.Clear();
            dte_Ngaynghicongtac.DataBindings.Clear();
            dte_Ngaysinh.DataBindings.Clear();
            dte_Ngaythamgiacongtac.DataBindings.Clear();
            cbo_Dantoc.DataBindings.Clear();
            cbo_Mabac.DataBindings.Clear();
            cbo_Maphongban.DataBindings.Clear();
            cbo_Tongiao.DataBindings.Clear();
            radio_Gioitinh.DataBindings.Clear();
            base.ClearDataBindings();
        }

        protected override void DataBindingControl()
        {
            txt_Manhanvien.DataBindings.Add("Text", _dtb, ".MANHANVIEN");
            txt_Hoten.DataBindings.Add("Text", _dtb, ".HOTEN");
            radio_Gioitinh.DataBindings.Add("Text", _dtb, ".GIOITINH");
            dte_Ngaysinh.DataBindings.Add("EditValue", _dtb, ".NGAYSINH");
            txt_Cmnd.DataBindings.Add("Text", _dtb, ".CMND");
            cbo_Dantoc.DataBindings.Add("EditValue", _dtb, ".DANTOC");
            cbo_Tongiao.DataBindings.Add("EditValue", _dtb, ".TONGIAO");
            txt_Quequan.DataBindings.Add("Text", _dtb, ".QUEQUAN");
            txt_Choohiennay.DataBindings.Add("Text", _dtb, ".CHOOHIENNAY");
            cbo_Hocvan.DataBindings.Add("EditValue", _dtb, ".TRINHDOHOCVAN");
            txt_Sodienthoai.DataBindings.Add("Text", _dtb, ".DIENTHOAI");
            txt_Email.DataBindings.Add("Text", _dtb, ".EMAIL");
            dte_Ngaythamgiacongtac.DataBindings.Add("EditValue", _dtb, ".NGAYTHAMGIACONGTAC");
            dte_Ngaynghicongtac.DataBindings.Add("EditValue", _dtb, ".NGAYNGHICONGTAC");
            cbo_Mucluong.DataBindings.Add("EditValue", _dtb, ".MUCLUONG");
            txt_Hesoluong.DataBindings.Add("Text", _dtb, ".HESOLUONG");
            txt_Hesophucap.DataBindings.Add("Text", _dtb, ".HESOPHUCAP");
            txt_TenFile.DataBindings.Add("Text", _dtb, ".IMAGES");
            cbo_Mabac.DataBindings.Add("EditValue", _dtb, ".MABAC");
            txt_Tenbac.DataBindings.Add("Text", _dtb, ".TENBAC");
            cbo_Maphongban.DataBindings.Add("EditValue", _dtb, ".MAPHONGBAN");
            txt_Tenphongban.DataBindings.Add("Text", _dtb, ".TENPHONGBAN");
            txt_Tenchucvu.DataBindings.Add("Text", _dtb, ".TENCHUCVU");
            txt_Chuyenmon.DataBindings.Add("Text", _dtb, ".CHUYENMON");
            txt_Chungchingoaingu.DataBindings.Add("Text", _dtb, ".CHUNGCHI_NN");
            txt_Chungchitinhoc.DataBindings.Add("Text", _dtb, ".CHUNGCHI_TH");
            txt_Chungchisupham.DataBindings.Add("Text", _dtb, ".CHUNGCHI_SP");
            txt_Chungchichinhtri.DataBindings.Add("Text", _dtb, ".CHUNGNHAN");

            base.DataBindingControl();
        }

        protected override void ReadOnlyControl(bool isReadOnly = true)
        {
            txt_Manhanvien.Properties.ReadOnly = isReadOnly;
            txt_Hoten.Properties.ReadOnly = isReadOnly;
            radio_Gioitinh.Properties.ReadOnly = isReadOnly;
            dte_Ngaysinh.Properties.ReadOnly = isReadOnly;
            txt_Cmnd.Properties.ReadOnly = isReadOnly;
            txt_Choohiennay.Properties.ReadOnly = isReadOnly;
            txt_Chungchichinhtri.Properties.ReadOnly = isReadOnly;
            txt_Chungchingoaingu.Properties.ReadOnly = isReadOnly;
            txt_Chungchisupham.Properties.ReadOnly = isReadOnly;
            txt_Chungchitinhoc.Properties.ReadOnly = isReadOnly;
            txt_Chuyenmon.Properties.ReadOnly = isReadOnly;
            txt_Email.Properties.ReadOnly = isReadOnly;
            txt_Hesoluong.Properties.ReadOnly = isReadOnly;
            txt_Hesophucap.Properties.ReadOnly = isReadOnly;
            txt_Quequan.Properties.ReadOnly = isReadOnly;
            txt_Sodienthoai.Properties.ReadOnly = isReadOnly;
            txt_Tenbac.Properties.ReadOnly = isReadOnly;
            txt_Tenchucvu.Properties.ReadOnly = isReadOnly;
            txt_TenFile.Properties.ReadOnly = isReadOnly;
            txt_Tenphongban.Properties.ReadOnly = isReadOnly;
            cbo_Hocvan.Properties.ReadOnly = isReadOnly;
            cbo_Mucluong.Properties.ReadOnly = isReadOnly;
            dte_Ngaynghicongtac.Properties.ReadOnly = isReadOnly;
            dte_Ngaythamgiacongtac.Properties.ReadOnly = isReadOnly;
            cbo_Dantoc.Properties.ReadOnly = isReadOnly;
            cbo_Mabac.Properties.ReadOnly = isReadOnly;
            cbo_Maphongban.Properties.ReadOnly = isReadOnly;
            cbo_Tongiao.Properties.ReadOnly = isReadOnly;

            grcNhanvien.Enabled = isReadOnly;
            base.ReadOnlyControl(isReadOnly);
        }

        protected override bool UpdateObject()
        {
            return base.UpdateObject();
        }

        protected override bool InsertObject()
        {
            return base.InsertObject();
        }

        protected override void LoadData()
        {
            layoutControlItemBrowse.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;

            _dtb = _dal.Select();
            _dtb1 = _dal.Select_Phongban();
            _dtb2 = _dal.Select_Mucluong();
            _dtb3 = _dal.Select_Bachoc();
            _dtb4 = _dal.Select_Dantoc();
            _dtb5 = _dal.Select_Tongiao();
            _dtb6 = _dal.Select_Hocvan();

            cbo_Maphongban.Properties.DataSource = _dtb1;
            cbo_Mucluong.Properties.DataSource = _dtb2;
            cbo_Mabac.Properties.DataSource = _dtb3;
            cbo_Dantoc.Properties.DataSource = _dtb4;
            cbo_Tongiao.Properties.DataSource = _dtb5;
            cbo_Hocvan.Properties.DataSource = _dtb6;

            if (_dtb != null)
            {
                grcNhanvien.DataSource = _dtb;

                try
                {
                    string fileName = grvNhanvien.GetFocusedDataRow()["Images"].ToString();
                    pic_Hinh.Image = Image.FromFile(fileName);
                    pic_Hinh.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                catch { }

                try
                {
                    AppGridView.InitGridView(grvNhanvien, true, false, DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect, false, false, "Nhấn vào đây để thêm mới");
                    AppGridView.ShowField(grvNhanvien,
                        new string[] { "MANHANVIEN", "HOTEN" },
                        new string[] { "Mã nhân viên", "Họ và tên" },
                        new int[] { 100, 250 });
                    AppGridView.SummaryField(grvNhanvien, "MANHANVIEN", "Tổng = {0:#,0} Nhân viên", DevExpress.Data.SummaryItemType.Count);

                    grvNhanvien.OptionsBehavior.ReadOnly = true;
                    grvNhanvien.OptionsView.ColumnAutoWidth = true;

                }
                catch { }
               

            }

            base.LoadData();
        }

        #endregion

        #region Chọn ảnh
        private void bto_Browse_Click(object sender, EventArgs e)
        {
            OpenFileDialog FileAnh = new OpenFileDialog();
            FileAnh.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|Png Image|*.png";
            FileAnh.ShowDialog();


            txt_TenFile.Text = FileAnh.FileName;

            pic_Hinh.Image = Image.FromFile(FileAnh.FileName.ToString());
            pic_Hinh.SizeMode = PictureBoxSizeMode.StretchImage;
        }
        private void grvNhanvien_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            try
            {
                string fileName = grvNhanvien.GetFocusedDataRow()["Images"].ToString();
                pic_Hinh.Image = Image.FromFile(fileName.ToString());
                pic_Hinh.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            catch { }
        }
        #endregion

        #region "Thông báo"

        private void txt_Hoten_Validating(object sender, CancelEventArgs e)
        {
            if (txt_Hoten.Text + "" == "")
            {

                dxEP.SetError(txt_Hoten, "Họ tên không được trống");
            }
            else
                dxEP.SetError(txt_Hoten, "");
        }


        private void txt_Hesoluong_Validating(object sender, CancelEventArgs e)
        {
            if (txt_Hesoluong.Text + "" == "")
            {

                dxEP.SetError(txt_Hesoluong, "Hệ số lương không được trống");
            }
            else
                dxEP.SetError(txt_Hesoluong, "");
        }

        private void txt_Hesophucap_Validating(object sender, CancelEventArgs e)
        {
            if (txt_Hesophucap.Text + "" == "")
            {

                dxEP.SetError(txt_Hesophucap, "Hệ số phụ cấp không được trống");
            }
            else
                dxEP.SetError(txt_Hesophucap, "");
        }

        #endregion

    }
}
